From 70602906aef641f2b2ef93cde304f22339216dae Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sat, 2 Jun 2007 21:00:37 +0000 Subject: [PATCH] Remove depth from garmin special data. --- defs.h | 1 + g7towin.c | 2 +- garmin_fs.c | 22 ++++++++++------------ garmin_fs.h | 2 -- garmin_txt.c | 4 ++-- gdb.c | 21 ++++++++++++--------- gpilots.c | 2 +- mapsource.c | 12 +++++++----- unicsv.c | 2 +- 9 files changed, 35 insertions(+), 33 deletions(-) diff --git a/defs.h b/defs.h index d7367740f..92057a607 100644 --- a/defs.h +++ b/defs.h @@ -289,6 +289,7 @@ typedef struct { unsigned int proximity:1; /* proximity field is set */ unsigned int course:1; /* course field is set */ unsigned int speed:1; /* speed field is set */ + unsigned int depth:1; /* depth field is set */ /* !ToDo! unsigned int altitude:1; /+ altitude field is set +/ ... and others diff --git a/g7towin.c b/g7towin.c index a3e2517b1..2aca83e66 100644 --- a/g7towin.c +++ b/g7towin.c @@ -173,7 +173,7 @@ parse_line(char *buff, int index, const char *delimiter, waypoint *wpt) case WPT_cC_OFS + 2: case WPT_c5_OFS + 2: case WPT_c8_OFS + 2: - GMSD_SET(depth, altf * atof(cin)); + WAYPT_SET(wpt, depth, altf * atof(cin)); break; case TRKPT__OFS + 10: /* temperature */ diff --git a/garmin_fs.c b/garmin_fs.c index d9c9a5ece..2a584b9d7 100644 --- a/garmin_fs.c +++ b/garmin_fs.c @@ -102,7 +102,7 @@ garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt) if (gmsd == NULL) return; if ((gmsd->flags.category && gmsd->category) || - gmsd->flags.depth || + waypt->wpt_flags.depth || waypt->wpt_flags.proximity || waypt->wpt_flags.temperature || gmsd->flags.display) @@ -115,12 +115,12 @@ garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt) "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " \ "xsi:schemaLocation=\"http://www.garmin.com/xmlschemas/GpxExtensions/v2 " \ "http://www.garmin.com/xmlschemas/GpxExtensions/v2/GpxExtensionsv2.xsd\">\n", space++ * 2, ""); - if (waypt->wpt_flags.proximity) + if WAYPT_HAS(waypt, proximity) gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->proximity); - if (waypt->wpt_flags.temperature) + if WAYPT_HAS(waypt, temperature) gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->temperature); - if (gmsd->flags.depth) - gbfprintf(ofd, "%*s%.6f\n", space * 2, "", gmsd->depth); + if WAYPT_HAS(waypt, depth) + gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->depth); if (gmsd->flags.display) { char *cx; @@ -181,15 +181,13 @@ garmin_fs_xml_convert(const int base_tag, int tag, const char *cdatastr, waypoin */ switch(tag) { case 2: - waypt->proximity = atof(cdatastr); - waypt->wpt_flags.proximity = (*cdatastr); + if (*cdatastr) WAYPT_SET(waypt, proximity, atof(cdatastr)); break; case 3: - waypt->temperature = atof(cdatastr); - waypt->wpt_flags.temperature = (*cdatastr); + if (*cdatastr) WAYPT_SET(waypt, temperature, atof(cdatastr)); break; case 4: - GMSD_SET(depth, atof(cdatastr)); + if (*cdatastr) WAYPT_SET(waypt, depth, atof(cdatastr)); break; case 5: if (case_ignore_strcmp(cdatastr, "SymbolOnly") == 0) { @@ -281,7 +279,7 @@ garmin_fs_garmin_after_read(const GPS_PWay way, waypoint *wpt, const int protoid if (way->category != 0) GMSD_SET(category, way->category); if (way->dst < 1.0e25f) WAYPT_SET(wpt, proximity, way->dst); if (way->temperature_populated) WAYPT_SET(wpt, temperature, way->temperature); - if (way->dpth < 1.0e25f) GMSD_SET(depth, way->dpth); + if (way->dpth < 1.0e25f) WAYPT_SET(wpt, depth, way->dpth); GMSD_SETNSTR(cc, way->cc, sizeof(way->cc)); GMSD_SETNSTR(state, way->state, sizeof(way->state)); GMSD_SETSTR(city, way->city); @@ -303,7 +301,7 @@ garmin_fs_garmin_before_write(const waypoint *wpt, GPS_PWay way, const int proto way->dspl = gt_switch_display_mode_value( GMSD_GET(display, way->dspl), gps_waypt_type, 0); way->category = GMSD_GET(category, way->category); - way->dpth = GMSD_GET(depth, way->dpth); + way->dpth = WAYPT_GET(wpt, depth, way->dpth); way->dst = WAYPT_GET(wpt, proximity, way->dpth); way->temperature = WAYPT_GET(wpt, temperature, way->temperature); diff --git a/garmin_fs.h b/garmin_fs.h index eda53d320..7c1cd9ab8 100644 --- a/garmin_fs.h +++ b/garmin_fs.h @@ -68,7 +68,6 @@ typedef struct { unsigned int wpt_class:1; unsigned int display:1; unsigned int category:1; - unsigned int depth:1; unsigned int city:1; unsigned int state:1; unsigned int facility:1; @@ -91,7 +90,6 @@ typedef struct garmin_fs_s int wpt_class; gbint32 display; gbint16 category; - double depth; /* depth in meters */ char *city; /* city name */ char *facility; /* facility name */ char *state; /* state */ diff --git a/garmin_txt.c b/garmin_txt.c index 7f17f0b19..baa63b7db 100644 --- a/garmin_txt.c +++ b/garmin_txt.c @@ -576,7 +576,7 @@ write_waypt(const waypoint *wpt) print_distance(wpt->altitude, 1, 0); gbfprintf(fout, "\t"); - x = GMSD_GET(depth, unknown_alt); + x = WAYPT_GET(wpt, depth, unknown_alt); if (x != unknown_alt) print_distance(x, 1, 0); gbfprintf(fout, "\t"); @@ -1129,7 +1129,7 @@ parse_waypoint(void) &wpt->latitude, &wpt->longitude, MYNAME); break; case 5: if (parse_distance(str, &d)) wpt->altitude = d; break; - case 6: if (parse_distance(str, &d)) GMSD_SET(depth, d); break; + case 6: if (parse_distance(str, &d)) WAYPT_SET(wpt, depth, d); break; case 7: if (parse_distance(str, &d)) WAYPT_SET(wpt, proximity, d); break; case 8: if (parse_temperature(str, &d)) WAYPT_SET(wpt, temperature, d); break; case 9: if (parse_display(str, &i)) GMSD_SET(display, i); break; diff --git a/gdb.c b/gdb.c index 96fe4bd49..5f689122f 100644 --- a/gdb.c +++ b/gdb.c @@ -103,8 +103,8 @@ /*******************************************************************************/ -/* static char gdb_release[] = "$Revision: 1.52 $"; */ -static char gdb_release_date[] = "$Date: 2007/05/25 10:13:21 $"; +/* static char gdb_release[] = "$Revision: 1.53 $"; */ +static char gdb_release_date[] = "$Date: 2007/06/02 21:00:37 $"; static gbfile *fin, *fout; static int gdb_ver, gdb_category, gdb_via, gdb_roadbook; @@ -536,7 +536,7 @@ read_waypoint(gt_waypt_classes_e *waypt_class_out) if (FREAD_C == 1) { double depth = gbfgetdbl(fin); - GMSD_SET(depth, depth); + WAYPT_SET(res, depth, depth); #if GDB_DEBUG DBG(GDB_DBG_WPTe, 1) printf(MYNAME "-wpt \"%s\" (%d): Depth = %.1f\n", @@ -896,10 +896,10 @@ read_track(void) wpt->creation_time = FREAD_i32; } if (FREAD_C == 1) { - wpt->depth = gbfgetdbl(fin); + WAYPT_SET(wpt, depth, gbfgetdbl(fin)); } if (FREAD_C == 1) { - wpt->temperature = gbfgetdbl(fin); + WAYPT_SET(wpt, temperature, gbfgetdbl(fin)); } track_add_wpt(res, wpt); @@ -1154,7 +1154,7 @@ write_waypoint( FWRITE_LATLON(wpt->longitude); /* longitude */ FWRITE_DBL(wpt->altitude, unknown_alt); /* altitude */ FWRITE_CSTR(wpt->notes); - FWRITE_DBL(WAYPT_GET(wpt, proximity, 0), 0); /* proximity */ + FWRITE_DBL(WAYPT_GET(wpt, proximity, unknown_alt), unknown_alt); /* proximity */ FWRITE_i32(display); /* display */ FWRITE_i32(0); /* color (colour) */ FWRITE_i32(icon); /* icon */ @@ -1162,7 +1162,7 @@ write_waypoint( FWRITE_CSTR(GMSD_GET(state, "")); /* state */ FWRITE_CSTR(GMSD_GET(facility, "")); /* facility */ FWRITE_C(0); /* unknown */ - FWRITE_DBL(GMSD_GET(depth, 0), 0); /* depth */ + FWRITE_DBL(WAYPT_GET(wpt, depth, unknown_alt), unknown_alt); /* depth */ /* VERSION DEPENDENT CODE */ if (gdb_ver <= GDB_VER_2) { @@ -1352,6 +1352,7 @@ write_track(const route_head *trk, const char *trk_name) QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) { + double d; waypoint *wpt = (waypoint *)elem; trkpt_ct++; /* increase informational number of written route points */ @@ -1360,8 +1361,10 @@ write_track(const route_head *trk, const char *trk_name) FWRITE_LATLON(wpt->longitude); FWRITE_DBL(wpt->altitude, unknown_alt); FWRITE_TIME(wpt->creation_time); - FWRITE_DBL(wpt->depth, unknown_alt); - FWRITE_DBL(wpt->temperature, 0); + d = WAYPT_GET(wpt, depth, unknown_alt); + FWRITE_DBL(d, unknown_alt); + d = WAYPT_GET(wpt, temperature, -99999); + FWRITE_DBL(d, -99999); } /* finalize track */ diff --git a/gpilots.c b/gpilots.c index 8fb1cbcc3..69a2f70a8 100644 --- a/gpilots.c +++ b/gpilots.c @@ -275,7 +275,7 @@ data_read(void) fi.i = le_read32(&rec->wpt.d108.alt); wpt_tmp->altitude = fi.f; fi.i = le_read32(&rec->wpt.d108.dpth); - wpt_tmp->depth = fi.f; + WAYPT_SET(wpt_tmp, depth, fi.f); fi.i = le_read32(&rec->wpt.d108.dist); WAYPT_SET(wpt_tmp, proximity, fi.f); wpt_tmp->wpt_flags.icon_descr_is_dynamic = 0; diff --git a/mapsource.c b/mapsource.c index 3825e7ab4..c5d4e3713 100644 --- a/mapsource.c +++ b/mapsource.c @@ -583,7 +583,7 @@ mps_waypoint_r(FILE *mps_file, int mps_ver, waypoint **wpt, unsigned int *mpscla thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon); thisWaypoint->altitude = mps_altitude; if (mps_proximity != unknown_alt) WAYPT_SET(thisWaypoint, proximity, mps_proximity); - thisWaypoint->depth = mps_depth; + if (mps_depth != unknown_alt) WAYPT_SET(thisWaypoint, depth, mps_depth); /* might need to change this to handle version dependent icon handling */ thisWaypoint->icon_descr = gt_find_desc_from_icon_number(icon, MAPSOURCE, &dynamic); @@ -617,10 +617,11 @@ mps_waypoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt, const int isRou double mps_altitude = wpt->altitude; double mps_proximity = (mpsuseprox ? WAYPT_GET(wpt, proximity, unknown_alt) : unknown_alt); - double mps_depth = (mpsusedepth ? wpt->depth : unknown_alt); + double mps_depth = unknown_alt; lat = GPS_Math_Deg_To_Semi(wpt->latitude); lon = GPS_Math_Deg_To_Semi(wpt->longitude); + if (WAYPT_HAS(wpt, depth) && mpsusedepth) mps_depth = wpt->depth; if(wpt->description) src = wpt->description; if(wpt->notes) src = wpt->notes; @@ -1024,7 +1025,7 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte) thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat); thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon); thisWaypoint->altitude = mps_altitude; - thisWaypoint->depth = mps_depth; + if (mps_depth != unknown_alt) WAYPT_SET(thisWaypoint, depth, mps_depth); } } @@ -1584,7 +1585,7 @@ mps_track_r(FILE *mps_file, int mps_ver, route_head **trk) thisWaypoint->creation_time = le_read32(&dateTime); thisWaypoint->microseconds = 0; thisWaypoint->altitude = mps_altitude; - thisWaypoint->depth = mps_depth; + if (mps_depth != unknown_alt) WAYPT_SET(thisWaypoint, depth, mps_depth); track_add_wpt(track_head, thisWaypoint); } /* while (trk_count--) */ @@ -1682,10 +1683,11 @@ mps_trackdatapoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt) char zbuf[10]; double mps_altitude = wpt->altitude; - double mps_depth = (mpsusedepth ? wpt->depth : unknown_alt); + double mps_depth = unknown_alt; lat = GPS_Math_Deg_To_Semi(wpt->latitude); lon = GPS_Math_Deg_To_Semi(wpt->longitude); + if (WAYPT_HAS(wpt, depth) && mpsusedepth) mps_depth = wpt->depth; memset(zbuf, 0, sizeof(zbuf)); diff --git a/unicsv.c b/unicsv.c index 04e061a97..42602a114 100644 --- a/unicsv.c +++ b/unicsv.c @@ -456,7 +456,7 @@ unicsv_parse_one_line(char *ibuf) break; case fld_depth: - wpt->depth = atof(s); + WAYPT_SET(wpt, depth, atof(s)); break; case fld_terminator: /* dummy */ -- 2.30.2